import * as Koa from "koa"
import * as Static from "koa-static";
import * as Router from "koa-router";
import * as Commander from "commander";

const cliargs = <CLIArgs><any>Commander.option("-p, --port [n]", 'Listen to porter',Number, 3000)
    .parse(process.argv);

const app = new Koa();
const router = new Router();


router
    .get("/", async (context, next) => {
        context.redirect("/main");
    });

app.use(Static(__dirname + "/wwwroot", {
    gzip: true,
    extensions: ['html', 'js']
}));

app.use(router.routes());
app.listen(cliargs.port);

console.log(`listening to ${cliargs.port}`);

interface CLIArgs {
    readonly port:Number
}